﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Yipusoft.ProfessionalTeam.BLL;
using Yipusoft.ProfessionalTeam.DAL;
using Yipusoft.SoldierArchives.BLL;
using Yipusoft.SoldierArchives.Model;

public partial class Combat_ProfessionalTeam_ViewProsGrade : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.UrlReferrer != null)
            {
                ViewState["UrlReferrer"] = Request.UrlReferrer.ToString();
            }
            BindGrade();
        }
    }

    void BindGrade()
    {
        string DepartmentId = Request["DepartmentId"];
        string IsCadre = Request["IsCadre"];
        string PersonId = Request["PersonId"];
        TeamDataContext tdc = new TeamDataContext();
        lblDepartmentId.Text = Yipusoft.Account.BLL.Department.GetDepartment(DepartmentId).FullName;

        if (IsCadre == "1")
        {
            Yipusoft.MapInfo.Model.SoldierArchiveInfo cadre = new Yipusoft.MapInfo.BLL.Cadre().GetSoldiersByWhere("CadreID='" + PersonId + "'").FirstOrDefault();
            if (cadre != null)
            {
                lblName.Text = cadre.CadreName;
            }
        }
        else
        {
            Yipusoft.SoldierArchives.BLL.Soldier soldier = new Yipusoft.SoldierArchives.BLL.Soldier();
            SoldierArchiveInfo soldierInfo = soldier.GetSoldierInfoByID(PersonId);
            if (soldierInfo != null)
            {
                lblName.Text = soldierInfo.SoldierName;
            }
        }
        ProsGrade grade = tdc.ProsGrade.Where(o => o.IsCadre == Convert.ToInt32(IsCadre) && o.personId == new Guid(PersonId)).FirstOrDefault();
        if (grade != null)
        {
            txtFWCGrade.Text = grade.FWCGrade;
            txtFWCSorce.Text = grade.FWCScore.ToString();
            txtYWQZGrade.Text = grade.YWQZGrade;
            txtYWQZSore.Text = grade.YWQZScore.ToString();
            txtDGGrade.Text = grade.DGGrade;
            txtDGSore.Text = grade.DGScore.ToString();
            txtSGGrade.Text = grade.SGGrade;
            txtSGSore.Text = grade.SGScore.ToString();
            txtRun5000Grade.Text = grade.Run5000Grade;
            txtRun5000Sore.Text = grade.Run5000Score.ToString();
            txt5000FGrade.Text = grade.Run5000FGrade;
            txtRun5000FSore.Text = grade.Run5000FScore.ToString();
            txt100FGrade.Text = grade.Run100FGrade;
            txtRunFSore.Text = grade.Run100FScore.ToString();
            txtTheory.Text = grade.TheoryScore.ToString();
            lblSumSore.Text = Convert.ToString(grade.FWCScore + grade.YWQZScore + grade.DGScore + grade.SGScore + grade.Run5000Score + grade.Run5000FScore + grade.Run100FScore + grade.TheoryScore);

        }

    }
}
